package com.binest.officeInformation.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.binest.common.annotation.Log;
import com.binest.common.core.controller.BaseController;
import com.binest.common.core.domain.AjaxResult;
import com.binest.common.enums.BusinessType;
import com.binest.officeInformation.domain.OfficeInformation;
import com.binest.officeInformation.service.IOfficeInformationService;
import com.binest.common.utils.poi.ExcelUtil;
import com.binest.common.core.page.TableDataInfo;

/**
 * 事务所信息Controller
 * 
 * @author binest
 * @date 2024-04-11
 */
@RestController
@RequestMapping("/officeInformation/")
public class OfficeInformationController extends BaseController
{
    @Autowired
    private IOfficeInformationService officeInformationService;

    /**
     * 查询事务所信息列表
     */
    @PreAuthorize("@ss.hasPermi('officeInformation:officeInformation:list')")
    @GetMapping("/list")
    public TableDataInfo list(OfficeInformation officeInformation)
    {
        startPage();
        List<OfficeInformation> list = officeInformationService.selectOfficeInformationList(officeInformation);
        return getDataTable(list);
    }

    /**
     * 导出事务所信息列表
     */
    @PreAuthorize("@ss.hasPermi('officeInformation:officeInformation:export')")
    @Log(title = "事务所信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OfficeInformation officeInformation)
    {
        List<OfficeInformation> list = officeInformationService.selectOfficeInformationList(officeInformation);
        ExcelUtil<OfficeInformation> util = new ExcelUtil<OfficeInformation>(OfficeInformation.class);
        util.exportExcel(response, list, "事务所信息数据");
    }

    /**
     * 获取事务所信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('officeInformation:officeInformation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(officeInformationService.selectOfficeInformationById(id));
    }

    /**
     * 新增事务所信息
     */
    @PreAuthorize("@ss.hasPermi('officeInformation:officeInformation:add')")
    @Log(title = "事务所信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OfficeInformation officeInformation)
    {
        return toAjax(officeInformationService.insertOfficeInformation(officeInformation));
    }

    /**
     * 修改事务所信息
     */
    @PreAuthorize("@ss.hasPermi('officeInformation:officeInformation:edit')")
    @Log(title = "事务所信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OfficeInformation officeInformation)
    {
        return toAjax(officeInformationService.updateOfficeInformation(officeInformation));
    }

    /**
     * 删除事务所信息
     */
    @PreAuthorize("@ss.hasPermi('officeInformation:officeInformation:remove')")
    @Log(title = "事务所信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(officeInformationService.deleteOfficeInformationByIds(ids));
    }
}
